<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="generator" content="ApiGen; http://apigen.org" />

	<title>Class Nette\IO\SafeStream</title>

	<link rel="stylesheet" href="resources/style.css?v=2011071314" type="text/css" media="all" />
	<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	<link rel="search" href="opensearch.xml" type="application/opensearchdescription+xml" title="Nette Framework API documentation" />
	<script type="text/javascript" src="resources/combined.js"></script>
	<script type="text/javascript" src="allclasses.js"></script>
</head>

<body>
<div id="left">
	<a href="allclasses.html">All Classes</a>

	<h3>Namespaces</h3>
	<ul>
		<li><a href="namespace-none.html">none</a>
		</li>
		<li><a href="namespace-Nette.html">Nette</a>
		</li>
		<li><a href="namespace-Nette.Application.html">Nette\Application</a>
		</li>
		<li><a href="namespace-Nette.Caching.html">Nette\Caching</a>
		</li>
		<li><a href="namespace-Nette.Collections.html">Nette\Collections</a>
		</li>
		<li><a href="namespace-Nette.Config.html">Nette\Config</a>
		</li>
		<li><a href="namespace-Nette.Forms.html">Nette\Forms</a>
		</li>
		<li class="active"><a href="namespace-Nette.IO.html">Nette\IO</a>
		</li>
		<li><a href="namespace-Nette.Loaders.html">Nette\Loaders</a>
		</li>
		<li><a href="namespace-Nette.Mail.html">Nette\Mail</a>
		</li>
		<li><a href="namespace-Nette.Reflection.html">Nette\Reflection</a>
		</li>
		<li><a href="namespace-Nette.Security.html">Nette\Security</a>
		</li>
		<li><a href="namespace-Nette.Templates.html">Nette\Templates</a>
		</li>
		<li><a href="namespace-Nette.Web.html">Nette\Web</a>
		</li>
		<li><a href="namespace-PHP.html">PHP</a>
		</li>
	</ul>

	<hr />

	<h3>Classes</h3>

	<ul>
		<li class="active"><a href="Nette.IO.SafeStream.html">SafeStream</a></li>
	</ul>


</div>

<div id="right">
	<form action="http://www.google.com/cse" id="search" onsubmit="if(this.q.value.indexOf('more:')==-1)this.q.value+=' more:api'">
		<input type="hidden" name="cx" value="011549293477758430224:vxofa9ufnhc" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" class="text" /><input type="submit" value="Search" />
	</form>

<div id="navigation">
	<ul>
		<li><a href="overview.html" title="Summary of all namespaces">Overview</a></li>
		<li><a href="namespace-Nette.IO.html" title="Summary of Nette\IO">Namespace</a></li>
		<li class="active">Class</li>
		<li><a href="elements.html">Elements</a></li>
	</ul>
</div>

<div id="content">
	<div id="classSummary">
		<p>namespace <a href="namespace-Nette.IO.html">Nette\IO</a></p>

		<h1>Class SafeStream</h1>

		<div class="classDescription">
		
<p>Thread safe / atomic file manipulation. Stream safe://</p>

<pre>
<span class="php-keyword2">file_put_contents</span>(<span
class="php-quote">'safe://myfile.txt'</span>, <span
class="php-var">$content</span>);

<span class="php-var">$content</span> = <span
class="php-keyword2">file_get_contents</span>(<span
class="php-quote">'safe://myfile.txt'</span>);

<span
class="php-keyword2">unlink</span>(<span
class="php-quote">'safe://myfile.txt'</span>);
</pre>

		</div>




		<div class="classInfo">
			<b>Final Class</b><br />
				<b>Author:</b> David Grudl<br />
			<b>Located at</b> <a href="source-Utils.SafeStream.php.html#18">/Utils/SafeStream.php</a><br />
		</div>
	</div>


	<div id="methodSummary">
		<table class="summary">
		<caption>Method Summary</caption>
		<tr data-order="0 register" id="_register">
			<td align="right" width="1%"><code class="nowrap">
				 public static
				bool
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_register">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#61" title="go to source code"><b>register</b></a>(
			)</code>

			<div class="short">
				
<p>Registers protocol ‚safe://‘.</p>

			</div>

			<div class="detailed">
				
<p>Registers protocol ‚safe://‘.</p>




					<h4>Returns</h4>
					<div class="smallList">bool </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_open" id="_stream_open">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				bool
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_open">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#72" title="go to source code"><b>stream_open</b></a>(
					string
					<var>$path</var>, 
					string
					<var>$mode</var>, 
					int
					<var>$options</var>, 
					string
					<var>&amp; $opened_path</var>
			)</code>

			<div class="short">
				
<p>Opens file.</p>

			</div>

			<div class="detailed">
				
<p>Opens file.</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$path</code> string file name with stream protocol<br />
						<code>$mode</code> string mode – see fopen()<br />
						<code>$options</code> int STREAM_USE_PATH, STREAM_REPORT_ERRORS<br />
						<code>$opened_path</code> string full path<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">bool TRUE on success or FALSE on failure</div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_close" id="_stream_close">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				void
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_close">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#159" title="go to source code"><b>stream_close</b></a>(
			)</code>

			<div class="short">
				
<p>Closes file.</p>

			</div>

			<div class="detailed">
				
<p>Closes file.</p>






			</div>
			</td>
		</tr>
		<tr data-order="1 stream_read" id="_stream_read">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				string
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_read">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#183" title="go to source code"><b>stream_read</b></a>(
					int
					<var>$length</var>
			)</code>

			<div class="short">
				
<p>Reads up to length bytes from the file.</p>

			</div>

			<div class="detailed">
				
<p>Reads up to length bytes from the file.</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$length</code> int length<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">string </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_write" id="_stream_write">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				int
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_write">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#195" title="go to source code"><b>stream_write</b></a>(
					string
					<var>$data</var>
			)</code>

			<div class="short">
				
<p>Writes the string to the file.</p>

			</div>

			<div class="detailed">
				
<p>Writes the string to the file.</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$data</code> string data to write<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">int number of bytes that were successfully stored</div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_tell" id="_stream_tell">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				int
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_tell">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#214" title="go to source code"><b>stream_tell</b></a>(
			)</code>

			<div class="short">
				
<p>Returns the position of the file.</p>

			</div>

			<div class="detailed">
				
<p>Returns the position of the file.</p>




					<h4>Returns</h4>
					<div class="smallList">int </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_eof" id="_stream_eof">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				bool
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_eof">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#225" title="go to source code"><b>stream_eof</b></a>(
			)</code>

			<div class="short">
				
<p>Returns TRUE if the file pointer is at end-of-file.</p>

			</div>

			<div class="detailed">
				
<p>Returns TRUE if the file pointer is at end-of-file.</p>




					<h4>Returns</h4>
					<div class="smallList">bool </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_seek" id="_stream_seek">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				int
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_seek">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#236" title="go to source code"><b>stream_seek</b></a>(
					int
					<var>$offset</var>, 
					int
					<var>$whence</var>
			)</code>

			<div class="short">
				
<p>Sets the file position indicator for the file.</p>

			</div>

			<div class="detailed">
				
<p>Sets the file position indicator for the file.</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$offset</code> int position<br />
						<code>$whence</code> int see fseek()<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">int Return TRUE on success</div>


			</div>
			</td>
		</tr>
		<tr data-order="1 stream_stat" id="_stream_stat">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				array
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_stream_stat">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#249" title="go to source code"><b>stream_stat</b></a>(
			)</code>

			<div class="short">
				
<p>Gets information about a file referenced by $this-&gt;handle.</p>

			</div>

			<div class="detailed">
				
<p>Gets information about a file referenced by $this-&gt;handle.</p>




					<h4>Returns</h4>
					<div class="smallList">array </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 url_stat" id="_url_stat">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				array
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_url_stat">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#260" title="go to source code"><b>url_stat</b></a>(
					string
					<var>$path</var>, 
					int
					<var>$flags</var>
			)</code>

			<div class="short">
				
<p>Gets information about a file referenced by filename.</p>

			</div>

			<div class="detailed">
				
<p>Gets information about a file referenced by filename.</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$path</code> string file name<br />
						<code>$flags</code> int STREAM_URL_STAT_LINK, STREAM_URL_STAT_QUIET<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">array </div>


			</div>
			</td>
		</tr>
		<tr data-order="1 unlink" id="_unlink">
			<td align="right" width="1%"><code class="nowrap">
				 public 
				bool
				
				</code>
			</td>

			<td>
			<a class="anchor" href="#_unlink">#</a>
			<code class="nowrap">
				<a href="source-Utils.SafeStream.php.html#275" title="go to source code"><b>unlink</b></a>(
					string
					<var>$path</var>
			)</code>

			<div class="short">
				
<p>Deletes a file.</p>

			</div>

			<div class="detailed">
				
<p>Deletes a file.<br>
On Windows unlink is not allowed till file is opened</p>



					<h4>Parameters</h4>
					<div class="smallList">
						<code>$path</code> string file name with stream protocol<br />
					</div>

					<h4>Returns</h4>
					<div class="smallList">bool TRUE on success or FALSE on failure</div>


			</div>
			</td>
		</tr>

		</table>
	</div>




	<div id="constantSummary">
		<table class="summary">
		<caption>Constant Summary</caption>
		<tr data-order="PROTOCOL" id="PROTOCOL">
			<td align="right" width="1%"><code><b>PROTOCOL</b></code></td>
			<td><code><span class="php-quote">'safe'</span></code> <a href="#PROTOCOL" class="anchor">#</a></td>
		</tr>
		</table>
	</div>





</div>

	<div id="footer">
		Nette Framework API documentation generated by <a href="http://apigen.org">ApiGen</a>
	</div>
</div>
</body>
</html>
